#include <bits/stdc++.h>
#define ll long long
#define isok cout << "ok" << endl
#define db(s,a) cout << s << ":" << a << endl
#define dbarr(a,n) for(ll i=1;i<=n;i++) cout << a[i] << " " ; cout << endl
#define read(n) scanf("%lld",&n)
#define write(n) printf("%lld",(n))
using namespace std ;
ll t , n , m , L , V , i , cnt , maxx = -1 , d[100005] , v[100005] , p[100005] , a[100005] ;
int main(){
    freopen("detect.in","r",stdin) ;
    freopen("detect.out","w",stdout) ;
    read(t) ;
    while(t--){
        read(n) ;
        read(m) ;
        read(L) ;
        read(V) ;
        maxx = -1 ;
        cnt = 0 ;
        for(i=1;i<=n;i++){
            read(d[i]) ;
            read(v[i]) ;
            read(a[i]) ;
        }
        for(i=1;i<=m;i++){
            read(p[i]) ;
            maxx = max(maxx,p[i]) ;
        }
        for(i=1;i<=n;i++){
            if(d[i]>maxx){
                continue ;
            }
            if(sqrt((long double)(v[i]*v[i]+2*a[i]*(maxx-d[i])))>(long double)V){
                cnt++ ;
            }
        }
        printf("%lld %lld\n",cnt,m-1) ;
    }
    return 0 ;
}
